package org.csu.jpetstore_user.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import org.apache.ibatis.type.JdbcType;

import java.util.Base64;

@Data
@TableName("product")
public class Product {
    @TableId(value = "productid",type = IdType.INPUT)
    private String productId;
    @TableField(value = "category")
    private String categoryId;
    @TableField(value = "name")
    private String name;
    @TableField(value = "images", jdbcType = JdbcType.BLOB)
    private byte[] images;
    @TableField(value = "descn")
    private String description;

    public static String convertToDataUrl(byte[] bytes) {
        return "data:image/png;base64," + Base64.getEncoder().encodeToString(bytes);
    }
}


